<?php
namespace Admin\Controller;

class ApiController extends BaseController {
    /*
     * 获取地区
     */
    public function getRegion(){
        $parent_id = I('get.parent_id');
        $data = M('region')->where("parent_id=$parent_id")->select();
        $html = '';
        if($data){
            foreach($data as $h){
                $html .= "<option value='{$h['id']}'>{$h['name']}</option>";
            }
        }
        echo $html;
    }

    public function get_category(){
        $parent_id = I('get.parent_id'); // 商品分类 父id
        $list = M('goods_category')->where("parent_id = $parent_id")->select();
        $html = '';
        foreach($list as $k => $v)
            $html .= "<option value='{$v['id']}'>{$v['name']}</option>";
        exit($html);
    }
}